home *** CD-ROM | disk | FTP | other *** search
/ Rat Attack (UK) (Digital Press Kit - Summer '99) / Rat Attack (UK) (Digital Press Kit - Summer '99).bin / RAT01.DIR / 00007_Script_Image Switch Cast Members < prev    next >
Text File  |  1999-04-26  |  5KB  |  131 lines

  1. -- Image Switch Members
  2.  
  3. -- Media
  4.  
  5. -- Adding this behavior to a sprite allows it to change its cast member when
  6. -- it receives an event.
  7. -- The sprite checks the parameter passed with the event and if it matches the
  8. -- assigned name of the sprite or the assigned 'groupname' of the sprite
  9. -- it switches.  This way multiple sprites can be effected by a single message.
  10.  
  11. -- autohandles MemberAlt, MemberOne being numbers or labels.
  12.  
  13. -- MemberAlt is a cast member (graphic or pict)
  14. -- MemberOne is also
  15. -- Setting is with 1 ( normal ) or 2 ( toggled ) and is also starting state
  16. -- Name is a symbol which is checked for when the script receives a Switch event
  17. -- GroupName is also a symbol checked for, must be a symbol
  18.  
  19. -- receives Switch name
  20.  
  21. property  Name, Setting, Memberalt, MemberOne, GroupName
  22. property MemberAltName 
  23.  
  24. on SetState me, state, addressee
  25.   if voidP(Addressee) then
  26.     do_SetState me, state
  27.   else    
  28.     case Addressee of
  29.       #all: do_SetState me, state
  30.       (the Name of me): do_SetState me, state
  31.       (the GroupName of me): do_SetState me, state
  32.     end case
  33.   end if
  34. end
  35.  
  36. on SwitchStates me, Addressee 
  37.   if voidP( Addressee ) then
  38.     do_SwitchStates me
  39.   else    
  40.     case Addressee of
  41.       #all: do_SwitchStates me
  42.       (the Name of me): do_SwitchStates me
  43.       (the GroupName of me): do_SwitchStates me
  44.     end case
  45.   end if 
  46. end
  47.  
  48. ---
  49. on do_SetState me, state 
  50.   set the Setting of me = state
  51.   if state = 1 then
  52.     set the member of sprite the spritenum of me to the MemberOne of me
  53.   else
  54.     set the member of sprite the spritenum of me to the MemberAlt of me
  55.   end if
  56. end
  57.  
  58. on do_SwitchStates me
  59.   if ( the Setting of me = 1 ) then
  60.     set the Setting of me = 2
  61.     set the member of sprite the spritenum of me to the MemberAlt of me
  62.   else if ( the Setting of me = 2 ) then
  63.     set the Setting of me = 1
  64.     set the member of sprite the spritenum of me to the MemberOne of me
  65.   end if
  66.   return the Setting of me
  67. end
  68.  
  69. ---
  70.  
  71. on BeginSprite me
  72.   
  73.   set the MemberOne of me = the member of sprite ( the spriteNum of me ) 
  74.   set the MemberAlt of me = member ( the MemberAltName of me ) 
  75.   
  76.   if setting = TRUE then -- initially alternate
  77.     do_SetState me, 2 
  78.   else  -- initally memberOne.
  79.     do_SetState me, 1 
  80.   end if 
  81. end
  82.  
  83. on getPropertyDescriptionList
  84.   if the currentspritenum = 0 then 
  85.     set memdefault = 0 
  86.   else
  87.     set memref = the member of sprite the currentspritenum
  88.     set castlibnum = the castlibnum of memref
  89.     set memdefault = member (the membernum of member memref + 1) of castlib castlibnum
  90.   end if
  91.   
  92.   set p_list = [ ¼
  93.           #Name: [ #comment:   "Item Name:", ¼
  94.                     #format:   #symbol, ¼
  95.                    #default:   #twostate1 ], ¼
  96.      #MemberAltName: [ #comment:   "Alternate Image Name:", ¼
  97.                    #format:   #graphic, ¼
  98.                    #default:    memdefault], ¼
  99.        #Setting: [ #comment:   "Initially Toggled:", ¼
  100.                     #format:   #boolean, ¼
  101.                    #default:    FALSE ], ¼
  102.      #GroupName: [ #comment:   "Group Name:", ¼
  103.                     #format:   #symbol, ¼
  104.                    #default:   #group1 ] ¼
  105.                  ]
  106.   
  107.   return p_list  
  108.   
  109. end
  110.  
  111. on getBehaviorDescription
  112.   return ¼
  113. "Switches cast members when the SwitchStates message is received. Switches to a particular state when the SetState message is received. Enter a Group Name to include the current sprite in a group of sprites that respond to the same message. " & RETURN & ¼
  114. "PARAMETERS:" & RETURN & ¼
  115. "ò Item Name - (optional) Enter an item name to identify the current sprite so that it can receive a specific message. Do not use spaces. Use the name as an argument for the Message Sprite or Message All Sprites behaviors."  & RETURN & ¼
  116. "ò Alternate Image - number of castmember whose image will replace normal image.  Must be stored in same cast library as Normal castmember."  & RETURN & ¼
  117. "ò Initially Toggled - Turn this option on if sprite's current cast member represents the alternate rather than the normal state of the sprite."  & RETURN & ¼
  118. "ò Group Name - (optional) Enter a Group Name to include the current sprite in a group of sprites that respond to the same message. Do not use spaces. Use the name as an argument for the Message Sprite or Message All Sprites behaviors."  & RETURN & ¼
  119. "MESSAGES:" & RETURN & ¼
  120. "ò SwitchStates [ID] - Switches the sprite's cast member. ID is the Item Name or Group Name of the sprite. Returns the current state of the sprite, 0 (normal) or 1 (alternate)."& RETURN & ¼
  121. "ò SetState {0 or 1}, [ID] - Sets the sprite to state 0 (normal) or 1 (alternate). ID is the Item Name or Group Name of the sprite. If the ID is omitted any sprite receiving the message will SetState."
  122.   
  123. end
  124.  
  125.  
  126.  
  127. on getAssocMembers --added, fmk
  128.   set myPropList = [MemberAltName ]
  129.   
  130.   return myPropList
  131. end getAssocMembers